<table>
	<tr>
		<td>
			<a class="button" href="<?php echo $this->baseUrl() ?>/cpusers/list">
				<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/left_16.png);" class="inb">Wróć do listy</div>
			</a>
		</td>
		<td>
			<a class="button" href="javascript:void(null)" onclick="$('#formitem').submit()">
				<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/save_16.png);" class="inb">Zapisz</div>
			</a>
		</td>
	</tr>
</table>

<form id="formitem" action="<?php echo $this->baseUrl() ?>/cpusers/item<?php echo isSet( $this->u_id ) ? '/id/' . $this->u_id : '' ?>/type/<?php echo $this->type; ?>" method="post">
<input type="hidden" name="role" value="<?php echo $this->type; ?>" />
<table cellspacing="0" cellpadding="6" class="tform">
	<tr>
		<td class="lb">Email:</td>
		<td class="inpy">
			<?php if( isSet( $this->err_email ) ) { ?>
				<input style="border:1px solid red;" type="text" name="email" value="" />
				<div class="formerror"><?php echo $this->err_email ?></div>
			<?php } else { ?>
				<input type="text" name="email" value="<?php echo $this->email ?>" />
			<?php } ?>
		</td>
	</tr>
	<tr>
		<td class="lb">Hasło:</td>
		<td class="inpy">
			<input type="password" name="pass" value="" />
		</td>
	</tr>
	<tr>
		<td class="lb">Język sklepu:</td>
		<td class="inpy">
			<?php echo $this->formSelect( 'langs_l_id', $this->langs_l_id, null, $this->langslist ); ?>
		</td>
	</tr>
	<tr>
		<td class="lb">Imie:</td>
		<td class="inpy">
			<input type="text" name="name" value="<?php echo $this->name ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Nazwisko:</td>
		<td class="inpy">
			<input type="text" name="surname" value="<?php echo $this->surname ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Telefon:</td>
		<td class="inpy">
			<input type="text" name="surname" value="<?php echo $this->surname ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Nazwa firmy:</td>
		<td class="inpy">
			<input type="text" name="company_name" value="<?php echo $this->company_name ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Nip:</td>
		<td class="inpy">
			<input type="text" name="nip" value="<?php echo $this->nip ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Ulica:</td>
		<td class="inpy">
			<input type="text" name="street" value="<?php echo $this->street ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Nr domu:</td>
		<td class="inpy">
			<input type="text" name="nr_home" value="<?php echo $this->nr_home ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Nr mieszkania:</td>
		<td class="inpy">
			<input type="text" name="nr_flat" value="<?php echo $this->nr_flat ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Kod pocztowy:</td>
		<td class="inpy">
			<input type="text" name="zip" value="<?php echo $this->zip ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Miejscowość:</td>
		<td class="inpy">
			<input type="text" name="locality" value="<?php echo $this->locality ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Województwo:</td>
		<td class="inpy">
			<?php echo $this->formSelect( 'province', $this->province, null, Core_Static::$province ) ?>
		</td>
	</tr>
	<tr>
		<td class="lb">Kraj:</td>
		<td class="inpy">
			<?php echo $this->formSelect( 'country', ( $this->country ) ? $this->country : 'PL', null, Core_Static::$country ) ?>
		</td>
	</tr>

	<tr>
		<td class="lb">Ulica (do wysyłki):</td>
		<td class="inpy">
			<input type="text" name="street_to_dispatch" value="<?php echo $this->street_to_dispatch ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Nr domu (do wysyłki):</td>
		<td class="inpy">
			<input type="text" name="nr_home_to_dispatch" value="<?php echo $this->nr_home_to_dispatch ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Nr mieszkania (do wysyłki):</td>
		<td class="inpy">
			<input type="text" name="nr_flat_to_dispatch" value="<?php echo $this->nr_flat_to_dispatch ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Kod pocztowy (do wysyłki):</td>
		<td class="inpy">
			<input type="text" name="zip_to_dispatch" value="<?php echo $this->zip_to_dispatch ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Miejscowość (do wysyłki):</td>
		<td class="inpy">
			<input type="text" name="locality_to_dispatch" value="<?php echo $this->locality_to_dispatch ?>" />
		</td>
	</tr>
	<tr>
		<td class="lb">Województwo (do wysyłki):</td>
		<td class="inpy">
			<?php echo $this->formSelect( 'province_to_dispatch', $this->province_to_dispatch, null, Core_Static::$province ) ?>
		</td>
	</tr>
	<tr>
		<td class="lb">Kraj (do wysyłki):</td>
		<td class="inpy">
			<?php echo $this->formSelect( 'country_to_dispatch', ( $this->country_to_dispatch ) ? $this->country_to_dispatch : 'PL', null, Core_Static::$country ) ?>
		</td>
	</tr>

	<tr>
		<td class="lb">Status:</td>
		<td class="inpy">
			<?php echo $this->formSelect( 'state', $this->state, null, array(
				0 => 'Nieaktywny',
				2 => 'Aktywny'
			) ) ?>
		</td>
	</tr>
	<tr>
		<td class="lb">Ranga cenowa główna:</td>
		<td class="inpy">
			<div class="manitem">
				<?php $i = 0; foreach( Core_Static::$priceRank as $key => $price ) { ?>
					<?php if( !isSet( $this->u_id ) ) { ?>
					<label><input <?php echo ( $i < 1 ) ? 'checked="checked"' : ''; ?> type="radio" name="price_rank" value="<?php echo $key ?>" /> <?php echo $price; ?></label><br />
					<?php $i++; } else { ?>
					<label><input <?php echo ( $this->price_rank == $key ) ? 'checked="checked"' : ''; ?> type="radio" name="price_rank" value="<?php echo $key ?>" /> <?php echo $price; ?></label><br />
					<?php } ?>
				<?php } ?>
			</div>
		</td>
	</tr>
	<tr>
		<td class="lb">Rangi cenowe per producent:</td>
		<td class="inpy">
		<?php foreach( $this->manufacturers as $value ) { ?>
			<div class="manitem">
				<div class="name"><?php echo $value['name_pl']; ?></div>
				<?php $i = 0; foreach( Core_Static::$priceRank as $key => $price ) { ?>
					<?php if( !isSet( $this->u_id ) ) { ?>
					<label><input <?php echo (  $i < 1 ) ? 'checked="checked"' : ''; ?> type="radio" name="rank[<?php echo $value['m_id'] ?>]" value="<?php echo $key ?>" /> <?php echo $price; ?></label><br />
					<?php $i++; } else { ?>
					<label><input <?php echo ( isSet( $this->rank[$value['m_id']] ) && ( $this->rank[$value['m_id']] == $key ) ) ? 'checked="checked"' : ''; ?> type="radio" name="rank[<?php echo $value['m_id'] ?>]" value="<?php echo $key ?>" /> <?php echo $price; ?></label><br />
					<?php } ?>
				<?php } ?>
			</div>
		<?php } ?>
		</td>
	</tr>
	<?php if( $this->type == 2 ) { ?>
	<tr>
		<td class="lb">Prowizja agenta:</td>
		<td class="inpy">
			<input type="text" name="provision" value="<?php echo $this->provision; ?>" />
		</td>
	</tr>	
	<?php } ?>

</table>
</form>

<table>
	<tr>
		<td>
			<a class="button" href="<?php echo $this->baseUrl() ?>/cpusers/list">
				<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/left_16.png);" class="inb">Wróć do listy</div>
			</a>
		</td>
		<td>
			<a class="button" href="javascript:void(null)" onclick="$('#formitem').submit()">
				<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/save_16.png);" class="inb">Zapisz</div>
			</a>
		</td>
	</tr>
</table>